<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('海外仓发货装箱单')" />
	<th:block th:include="include :: businessCSS" />
	<style>
		.preservationBtn{padding: 10px;text-align: center;}
		.preservationBtn input{font-size: 16px;background-color: rgb(80, 138, 238);color: #fff;border: none;padding: 5px 30px;border-radius: 10px;cursor: pointer;}
		.layui-col-xs4 {min-width:225px !important;}
		.layui-form-label{width:160px !important; padding: 6px 0px !important; margin: 0px 0px 0px -10px !important;}
		.layui-input-block{margin-left: 150px !important;min-height: 42px !important;}
		.layui-form-item .layui-inline{margin-bottom: 0px !important;}
		.layui-input{height: 32px !important;}
	</style>
	
	<script th:src="@{/js/jquery/jquery.min.js}"></script>
	<script th:src="@{/js/jquery/jquery.cookie.js}"></script>
	<script th:src="@{/js/jquery/jquery.blockUI.min.js}"></script>
	<script th:src="@{/dhecp/js/dh-common.js?v=53}"></script>
	<script th:src="@{/dhecp/js/dh-ui.js?v=36}"></script>
	<script th:src="@{/dhecp/js/dh-motif-list.js?v=1}"></script>
	<script th:src="@{/js/jquery/jquery.validate.min.js}"></script>
	<script th:src="@{/js/jquery/jquery.validate.extend.js}"></script>
	
	<!-- businessJS -->
	<script th:src="@{/dhecp/js/dh-business.js?v=1}"></script>
	
	<!-- layui  -->
	<link rel="stylesheet" href="/plugins/layui/2.7.6/css/layui.css" media="all" />
	<script src="/plugins/layui/2.7.6/layui.js" charset="utf-8"></script>
	
	<!-- 基于laiui的表格 -->
	<script type="text/javascript" src="/plugins/layui/extends/sku/simple_table_delivery_box_detail_for_edit.js"></script>
</head>

<body class="no-skin">
<div class="main-container" id="main-container">
	<div class="main-content">
	<form class="layui-form head-form">
		<div class="topbtns">
			<div class="tpBtn">
				<ul class="layui-nav">
					<li class="layui-nav-item">
						<a href="javascript:;" class="layui-btn layui-btn-sm tp-save" lay-submit lay-filter="btn-save" id="btn-add"><span class="dhicon dh-zu4133_2" style="margin-right: 3px;"></span>保存</a>
					</li>
				</ul>
			</div>
		</div>
	    <div class="north" style="background-color: #fff;">
			<div class="forminput"></div>
    	</div>
		<div style="width: 100%;height: 10px;background: #f6f6f6;"></div>
		<div>
			<div style="width:100%; overflow:scroll; background-color: #FFFFFF;">
				<div id="simple_table_delivery_box_detail_for_edit">
				</div>
			</div>
			<script th:inline="javascript">
			var tableOfDeliveryBoxDetail = null;
			//使用layui的sku模块
			layui.use(['form', 'simple_table_delivery_box_detail_for_edit', 'jquery'], function(){
				var $ = layui.jquery,simple_table_delivery_box_detail_for_edit = layui.simple_table_delivery_box_detail_for_edit,form = layui.form;
			         	
				tableOfDeliveryBoxDetail = simple_table_delivery_box_detail_for_edit.init({ id:'simple_table_delivery_box_detail_for_edit', data: $.parseJSON(JSON.stringify([[${detailList}]])), pcode:'aaa'  });
			});
			</script>
		</div>
    </form>
	</div>
</div>

<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = "/storage/deliveryBox";
	var	k_fields=[];
	var fields = [[${fields}]];
	var fieldsList = [[${fieldsList}]];
	var fieldsHiddenList = [[${fieldsHiddenList}]];
	var gridColumns= [[${gridColumns}]];
	var all_fields= fieldsList;
	var $,layer,form,table;
	layui.use(['laydate','form','layer','jquery','util','element','upload'], function () {
		$ = layui.$,layer = layui.layer,form = layui.form,laydate = layui.laydate,util = layui.util,element=layui.element,upload = layui.upload;
		
		// 加载公共表头
		headcom();
		form.on('submit(btn-save)', function(data){
			var is_return = false//是否中断保存
			fieldsList.map((v,i)=>{
				if(v.fieldFrontRequired){
					if(!$('#'+v.fields).val()){
						layer.msg(v.fieldName+'不能为空')
						is_return=true
					}
				}
			})
			if(is_return) return;
			data.field['detailArr'] = JSON.stringify(tableOfDeliveryBoxDetail.getData());
			$.post("/storage/deliveryBox/editpost", data.field, function(res){
				layer.msg(res.msg);
				if(res.code==0){
					setTimeout(function(){
						window.location.reload();
					},500)
				}
			});
           return false;
       });

		$('.t_date').each(function(){
            var datetype=$(this).attr('datetype')
            laydate.render({
				elem:this
                ,type: datetype=='t_date'?'date':datetype=='t_datetime'?'datetime':datetype=='t_year'?'year':'month'
			})
		})


		// beforeInit();//表单初始化之前的动作集合
		// layui.element.render();

    });

	function getMoreAfter(fieldsList,fields,tindex,fieldName,fieldSearchType,isSearch,isLayer,res){//弹出框赋值回调
		if(fields=="name"){
			$('#name').val(res.name)
			$('#way').val(res.way)
			$('#length').val(res.length)
			$('#width').val(res.width)
			$('#height').val(res.height)
			$('#weight').val(res.weight)
		}else{
			$('#productID').val(res.code)
			$('#productName').val(res.name)
		}
        // var fNid=$('#fNid').val()
        // $.get("/purchase/purchaseplan/selectPlan?nid="+fNid,function(res){
        //     listData1=res.plan
        //     listData2=res.planSon
        //     table.reload('mjdhtable', {data:listData1});
        //     table.reload('zjdhtable', {data:listData2});
	    // });
    }

	/*]]>*/
</script>

</body>
</html>